<template>
    <div id="Common">
        <v-detail :detailData="inputData" :inputConfig="inputConfig" :rules="rules" ref="detail"></v-detail>
    </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
    name: "Common",
    mixins: [baseMixin],
    props: {
        inputData: {
            type: Object
        }
    },
    data() {
        return {
            addflag: false,
            whseidflag: false,
            rules: {
                storerkey: [
                    {required: true, trigger: 'blur'},
                ],
            },
        }
    },
    computed: {
        inputConfig() {
            return [
                [
                    {
                        type: "input",
                        label: this.$t('bill.customer'),
                        props: "storerkey",
                        disabled: this.addflag
                    },
                    {
                        type: "input",
                        label: this.$t('config.company'),
                        props: "company",
                        disabled: this.whseidflag
                    },
                    {
                        type: "input",
                        label: this.$t('common.desc'),
                        props: "description",
                        disabled: this.whseidflag
                    },
                ],
                [
                    {
                        type: "input",
                        label: this.$t('config.scacCode'),
                        props: "scac_Code",
                        disabled: this.whseidflag
                    },
                    {
                        type: "input",
                        label: this.$t('config.vatId'),
                        props: "vat",
                        disabled: this.whseidflag
                    },
                    {
                        type: "checkbox",
                        label: this.$t('config.isNeedWeight'),
                        props: "rtxneedweight",
                        disabled: this.whseidflag
                    },
                ],
                [
                    {
                        type: "checkbox",
                        label: this.$t('config.trayExchangeFollow'),
                        props: "containerexchangeflag",
                        disabled: this.whseidflag
                    }
                ]
            ]
        }
    },
    methods: {},
    mounted() {
        if (this.$store.state.wms.includes('WMWHSE')) {
            this.whseidflag = true;
            this.addflag = this.whseidflag;
        }

        if (Object.keys(this.$store.state.skip).length !== 0) {
            let data = this.$store.state.skip;
            if (data.newFlag) {
                this.addflag = false;
            } else {
                this.addflag = true;
            }
        } else if (this.$store.state.newFlag) {
            this.addflag = false;
        } else {
            this.addflag = true;
        }
    },
    components: {
        "v-detail": detail
    }
}
</script>

<style scoped>

</style>
